#ifndef __I2C_USER_H
#define __I2C_USER_H

#include "at32f413_board.h"
#include "i2c_application.h"

#define I2C_TIMEOUT                      0xFFFFFFFF
//#define I2C_TIMEOUT                      0x000000FF

#define I2C1_SPEED                       1000000
#define I2C1_ADDRESS                     0xA0

#define I2C1_PORT                        I2C1
#define I2C1_CLK                         CRM_I2C1_PERIPH_CLOCK

#define I2C1_SCL_PIN                     GPIO_PINS_6
#define I2C1_SCL_GPIO_PORT               GPIOB
#define I2C1_SCL_GPIO_CLK                CRM_GPIOB_PERIPH_CLOCK

#define I2C1_SDA_PIN                     GPIO_PINS_7
#define I2C1_SDA_GPIO_PORT               GPIOB
#define I2C1_SDA_GPIO_CLK                CRM_GPIOB_PERIPH_CLOCK

#define I2C1_DMA_CLK                     CRM_DMA1_PERIPH_CLOCK
#define I2C1_DMA_TX_CHANNEL              DMA1_CHANNEL6
#define I2C1_DMA_TX_IRQn                 DMA1_Channel6_IRQn

#define I2C1_DMA_RX_CHANNEL              DMA1_CHANNEL7
#define I2C1_DMA_RX_IRQn                 DMA1_Channel7_IRQn

// I2C2
#define I2C2_SPEED                       1000000
#define I2C2_ADDRESS                     0xA0

#define I2C2_PORT                        I2C2
#define I2C2_CLK                         CRM_I2C2_PERIPH_CLOCK

#define I2C2_SCL_PIN                     GPIO_PINS_6
#define I2C2_SCL_GPIO_PORT               GPIOF
#define I2C2_SCL_GPIO_CLK                CRM_GPIOF_PERIPH_CLOCK

#define I2C2_SDA_PIN                     GPIO_PINS_7
#define I2C2_SDA_GPIO_PORT               GPIOF
#define I2C2_SDA_GPIO_CLK                CRM_GPIOF_PERIPH_CLOCK

#define I2C2_DMA_CLK                     CRM_DMA1_PERIPH_CLOCK
#define I2C2_DMA_TX_CHANNEL              DMA1_CHANNEL4
#define I2C2_DMA_TX_IRQn                 DMA1_Channel4_IRQn

#define I2C2_DMA_RX_CHANNEL              DMA1_CHANNEL5
#define I2C2_DMA_RX_IRQn                 DMA1_Channel5_IRQn

void i2c_user_init(void);
void i2c2_user_init(void);

#endif // __I2C_USER_H
